package algorithm.easy;

public class Solution104 {
    //给定二叉树 [3,9,20,null,null,15,7]，
    //
    //     3
    //   / \
    //  9  20
    //    /  \
    //   15   7
    //
    // 返回它的最大深度 3 。
    public static int maxDepth(TreeNode root) {
        if(root ==null){
            return 0;
        }
        TreeNode left = root.left;
        TreeNode right = root.right;
        int leftC = maxDepth(left);
        int rightC = maxDepth(right);

        return leftC>rightC?leftC+1:rightC+1;


    }

    public static void main(String[] args){
        TreeNode treeNode = TreeNode.init94();
        System.out.println(maxDepth(treeNode));
    }
}
